linetime=`date`

lineip=` ip -o addr | grep  ppp98  | awk '{print $4}'`

cmd="speedtest-cli --source  ${lineip}"
echo ${cmd}
testresult=`${cmd}`

if [[ -n ${testresult} ]]; then
	sourceaddrss=` echo ${testresult} | awk -F[.][.]+  '{print $2}' | awk -F\( '{print $2}' | sed -e 's/)//g'`
	servername=` echo ${testresult} | awk -F[.][.]+  '{print $5}'  | awk -F'Hosted by' '{print $2}' | awk -F\) '{print $1}' | awk '{print $0")"}'`
	downloadspeed=`echo ${testresult} | awk -F[.][.]+  '{print $6}'  | awk '{print $2 " " $3}'`
	uploadspeed=`echo ${testresult} | awk -F[.][.]+  '{print $7}'  | awk '{print $2 " " $3}'  `

	line=`echo ${testresult} | awk -F[.][.]+  '{print $2 " "  $6 " " $7}' | sed -e 's/Testing//g'  | sed -e 's/upload speed//g' `

	result="${sourceaddrss} ' ' ${servername} ' ' ${downloadspeed} ' ' ${uploadspeed}"
else
	result=" ${cmd}的测试结果为空"
fi

echo ${linetime}  ":::"  ${result} >> /tmp/speedtest.test.result